package com.neuedu.javase.array;

/**
 * @author :金山老师
 * project: MyJavaSE
 * 描述 ： 数组的复制
 * @date : 2025/10/22 15:02 星期三
 */
public class ArrayCopy {


    public static void main(String[] args) {

        int array1[] = {    10,20,30,40,50};


        int start =  2;
        int len =2 ;


        int copyArray[] = new int[len];

        //复制的过程
        for (int i = 0; i < copyArray.length; i++) {
            copyArray[i] = array1[start++];
        }


        System.out.println("复制后的结果");

        for (int i = 0; i < copyArray.length; i++) {
            System.out.println(copyArray[i]);
        }


        System.out.println("使用系统工具  ");
        int aa[] = new int[] { 1, 2, 3, 4, 5 };
        int bb[] = new int[] { 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
        System.arraycopy(aa, 0, bb, 0, 5);
        // System.arraycopy(aa, 2, bb, 3, 3);


        //数组是引用类型，  字符串  + 数组，    字符串 +对象的toString---Object的toString
        System.out.println("aa = " + aa);
        for (int i = 0; i < aa.length; i++) {
            System.out.print(aa[i]+"\t");
        }
        System.out.println();
        System.out.println("bb = " + bb);
        for (int i = 0; i < bb.length; i++) {
            System.out.print(bb[i]+"\t");
        }

    }


//     二维


}
